;============================================================
; Example using leds
;============================================================
                absentry Entry 
		INCLUDE 'derivative.inc' 

Ram     equ     $1000
Rom     equ     $4000

Data    equ     Ram
Code    equ     Ram

Reset   equ     $fffe

tstk    equ     80
Stack_f equ     Code
Stack_i equ     Stack_f - tstk

; Reset Interrupt Vector
        org     Reset
        dc.w Entry
        
; Stack Definition
        org     Stack_i
Pilha   ds.b Stack_f - Stack_i

; Data
        org     Data
led_tab dc.b	$80,$40,$20,$10,$08,$04,$02,$01
	dc.b	$01,$02,$04,$08,$10,$20,$40,$80

; Code
        org     Code
        
Entry:
        lds     #Stack_f

        movb    #$ff,DDRB       ;configure port B for output
        bset    DDRJ, $02       ;configure PJ[1] pin for output
        bclr    PTJ,$02         ;enable LEDs to light
        
Forever:        
        ldaa    #16
        ldx     #led_tab
led_lp  movb    1,x+,PORTB        ; turn on one LED
        ldy     #5              ; wait for half a second
        jsr     delayby100ms
        dbne    a,led_lp         ; reach the end of the table yet?
        bra     Forever
        

delayby100ms:   ; errada
        pshx
        pulx
        rts                
        
end        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
                                